/**
 * @author Ice Zero
 * @param {string} init p/s: start the center server or a peer
 * @param {number} port the listening port
 */

const Server = require('./server.js');
const Client = require('./client.js');

function shellMode() {
  switch (process.argv[2]) {
    case '-c':
      new Client(process.argv[3], process.argv[4]);
      break;
    case '-s':
      new Server(process.argv[3]);
      break;
    default:
      console.log('Unknown options!');
  }
}

// `shellMode` would not fire when required.
if (!module.parent) {
  shellMode();
}

module.exports = {
  Server: Server,
  Client: Client
}
